#ifndef __WEBPAGEQUERY_H__
#define __WEBPAGEQUERY_H__

#include <map>
#include <set>
#include <vector>
#include <string>

using std::map;
using std::pair;
using std::set;
using std::vector;
using std::string;

// class SplitTool;
class WebPage;
class PageLibPreprocessor;

class WebPageQuery
{
public:
    WebPageQuery();
    ~WebPageQuery();

    string doQuery(const string &str);
    
    void LoadLibrary();
private:
    vector<double> getQueryWordsWeightVector(vector<string> &queryWords);
    bool executeQuery(const vector<string> &queryWords, map<int, vector<double>> &resultVec);
    string createJson(vector<int> &docIdVec, const vector<string> &queryWords);
    string returnNoAnswer();

private:
    // SplitTool *psplitTool;
    map<int, WebPage> _pageLib;
    map<int, pair<int, int>> _offsetLib;
    map<string, set<pair<int, double>>> _invertIndexTable;
};

#endif
